package com.niuniu.rushdorm.util;

import com.niuniu.rushdorm.pojo.entity.Log;
import com.niuniu.rushdorm.pojo.entity.OrderMessage;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class MQSender {

    @Autowired
    RabbitTemplate rabbitTemplate;

    public void sendMessage(OrderMessage message){
        rabbitTemplate.convertAndSend("directExchange","queue.order",JsonUtils.toJsonString(message));
    }
    public void sendMessage(Log log){
        rabbitTemplate.convertAndSend("directExchange","queue.log",JsonUtils.toJsonString(log));
    }

}
